package com.lenovo.lcdm.type.util;

import com.lenovo.lcdm.common.enums.CommonMsgEnum;
import com.lenovo.lcdm.common.exception.BusinessException;
import org.springframework.util.ObjectUtils;

import java.util.Objects;

/**
 * @author
 */
public class Checker {

    public static <T> T notEmpty(T t, String msg) {
        if (ObjectUtils.isEmpty(t)) {
            throw new BusinessException(msg, CommonMsgEnum.FAIL.getCode());
        }

        return t;
    }

    public static void notEquals(Object o1, Object o2, String msg) {
        if (!Objects.equals(o1, o2)) {
            throw new BusinessException(msg, CommonMsgEnum.FAIL.getCode());
        }
    }

    public static void equals(Object o1, Object o2, String msg) {
        if (!Objects.equals(o1, o2)) {
            throw new BusinessException(msg, CommonMsgEnum.FAIL.getCode());
        }
    }
}
